import router from '@system.router';
const app = getApp();

export default {
    data: {
        user: "",
        account: "",
        icon: [
            "common/images/user_icon/notpay.jpg",
            "common/images/user_icon/notsend.jpg",
            "common/images/user_icon/notreceived.jpg",
            "common/images/user_icon/notcomment.jpg",
            "common/images/user_icon/refund.jpg"
        ]
    },
    onInit() {
        this.updateLoginStatus();
    },
    go(path) {
        router.push({ uri: path });
    },
    goOrder(tab) {
        if (tab === 4)
            return this.go("pages/refund/refund");
        router.push({
            uri: "pages/orders/orders",
            params: { current_tab: ++tab }
        });
    },
    login() {
        if (!app.isLoggedIn()) {
            this.go("pages/login/login");
        } else {
            this.updateLoginStatus();
        }
    },
    updateLoginStatus() {
        if (app.isLoggedIn()) {
            this.user = app.getUser();
            this.account = "账号名称:" + app.getUser() + " [ ]";
        } else {
            this.user = "我的淘宝昵称";
            this.account = "账号名称:";
        }
    }
}
